<%@page import="sql.DBManagment"%>
<%@page import="sql.record.*"%>
<%@page import="java.util.*"%>
<%	
	User loginUser = new User();
	loginUser.userName = (String) session.getAttribute("loggedUser");
	User storedUser = new User();
	try  {
		List<User> userList = DBManagment.getRecord(loginUser);
		storedUser = userList.get(0);
	}catch(Exception e){
		%>
		<script type = "text/javascript" src = "script/end_session.js"></script>		
		<%
	}
 %>
<%
	User generalUser = new User();
	List<User> allUsers = DBManagment.getTable(generalUser);
%>
<script type="text/javascript" src="script/forms.js"></script>
<script type="text/javascript" src="script/mng_users.js"></script>
<div class="bodytext" style="padding: 12px;" align="justify">
<form name="mngForm" id="mngForm" class="tableForm">
<fieldset align="justify"><legend>Control Box</legend> <input
	type="text" id="searchBox" /><br />
<label for="srchOptions">Also Search By </label> <!---should be filled by a loop as well acording to the form field amount--->
<input type="checkbox" name="srchOptions" id="srchOptions" /><span
	class="checkBoxOption">Name</span><!---remove ids....---> <input
	type="checkbox" name="srchOptions" id="srchOptions" /><span
	class="checkBoxOption">Sur Name</span> <input type="checkbox"
	name="srchOptions" id="srchOptions" /><span class="checkBoxOption">Phone
Number</span> <br/>
<br/>
<input type="button" id="markAll" value="Mark All" /> <input
	type="button" id="UnMarkAll" value="Unmark All" /> <input
	type="button" id="deleteMarked" class="handleMarked"
	value="Delete Marked" /> <input type="button" id="setMarkedAdmin"
	class="handleMarked" value="Set Marked Admin" /></fieldset>
 <%
 	for (User u : allUsers) {
 %>
<div class="panel" align="justify" id=<%="\"" + u.userName + "\""%>>
<span class="orangetitle"> <input type="checkbox" name="mark"
	id="mark" value=<%="\"" + u.userName + "\""%> /> <%=u.userName%> <input
	type="hidden" value=<%="\"" + u.userName + "\""%> class="hiddenData" />
</span> <span class="bodytext"> <br />
<ul>
	<li><b>Given Name: </b><%=u.givenName%><input type="hidden"
		value=<%="\"" + u.givenName + "\""%> class="hiddenData" /></li>
	<li><b>Sur Name: </b><%=u.surName%><input type="hidden"
		value=<%="\"" + u.surName + "\""%> class="hiddenData" /></li>
	<li><b>Phone Number: </b><%=u.phoneNumber%><input type="hidden"
		value=<%="\"" + u.phoneNumber + "\""%> class="hiddenData" /></li>
	<%
		String uType = ((u.type > 0) ? "Admin" : "User");
	%>
	<li><b>User Type: </b><%=uType%><input type="hidden"
		value=<%="\"" + uType + "\""%> class="hiddenData" /></li>
</ul>
<input type="button" id=<%="\"" + u.userName + "Edit\""%>
	class="userEditBtn" value="Edit" /> </span></div>
<%
	}
%>
</form>
</div>
